package com.example.designpattern.test.testProtected.test;

import java.util.*;
import java.util.List;

public class Main3 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String s1 = input.nextLine();
        String s2 = "";
        List<String> list = new ArrayList<>();
        for (int i = s1.length() - 1; i >= 0; i--) {
            char c = s1.charAt(i);
            if (((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))) {
                s2 += c;
                if (i == 0) {
                    s2 = reverse(s2);
                    list.add(s2);
                }
            } else {
                if ((!s2.equals(""))) {
                    s2 = reverse(s2);
                    list.add(s2);
                    s2 = "";
                }
            }
        }
        for (int i = 0; i < list.size(); i++) {
            if (i != list.size() - 1) {
                System.out.print(list.get(i) + " ");
            } else {
                System.out.println(list.get(i));
            }
        }
    }

    public static String reverse(String s) {
        String result = "";
        for (int i = s.length() - 1; i >= 0; i--) {
            result += s.charAt(i);
        }
        return result;
    }
}
